package com.yootk.server;
import java.net.*;

public class UDPClient {
    public static void main(String[] args) throws Exception {
        DatagramSocket client = new DatagramSocket(9999);  // 绑定到9999端口
        byte data[] = new byte[1024];  // 数据缓冲区
        DatagramPacket packet = new DatagramPacket(data, data.length);

        System.out.println("【UDPClient】客户端等待服务端发送消息 ......");
        client.receive(packet);  // 阻塞等待接收数据

        System.out.println("【UDPClient】接收到消息，消息内容为：" +
                new String(data, 0, packet.getLength()));
        client.close();
    }
}